<?php

class ZFWork_Form extends ZFKiller_Form {

	private $_formName;

	public function __construct($formName, $options = null) {
		if (!isset($options['class'])) {
			$options['class'] = 'basic';
		}
		if (!isset($options['id'])) {
			$options['id'] = 'form_' . preg_replace('#[^a-z0-9]#i', '', $formName);
		}

		parent::__construct($options);

		$this
				->addElementPrefixPath('ZFWork_Form_Decorator', PATH_ZFEXTEND . '/ZFWork/Form/Decorator', Zend_Form::DECORATOR)
				->setMethod(Zend_Form::METHOD_POST)
		;

		if ((!isset($options['removeDecoratorForm'])) or ($options['removeDecoratorForm'] !== false)) {
			$this
					->removeDecorator('Form')
			;
		}

		$this->_formName = $formName;
	}

	public function createGroupButton(array $elements, $name, $options = null) {
		foreach ($elements as $elementName) {
			$this->getElement($elementName)->removeDecorator('DtDdWrapper');
		}

		$this->addDisplayGroup($elements, $name, $options);
		$dg = $this->getDisplayGroup($name);
		$dg->removeDecorator('Fieldset');
		$dg->removeDecorator('HtmlTag');
	}

}